package tmp;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.logging.Level;
import java.util.logging.Logger;

public class Main {

    public static void main(String[] args) {

        Main controller = new Main();


        controller.doSomeReflection();

    }

    public void doSomeReflection() {

        Double x, y, z;
        x = Double.valueOf(2);

        y = new AnyClass().f1(x);
        System.out.println("x,y: " + x + ", " + y);

        Method reflMethod;

        try {
            
            reflMethod = AnyClass.class.getMethod("f1", Double.class);
            Double res;
            res = (Double) reflMethod.invoke(new AnyClass(), Double.valueOf(100.0));
            System.out.println("res: " + res);
            
            reflMethod = AnyClass.class.getMethod("f2", int.class);
            int result;
            result = (Integer) reflMethod.invoke(new AnyClass(), 100);
            System.out.println("result: " + result);

            //f3 ist static
            reflMethod = AnyClass.class.getMethod("f3", Double.class);
            Double res3;
            res = (Double) reflMethod.invoke(AnyClass.class.getDeclaredMethod("f3", Double.class), Double.valueOf(100.0));
            System.out.println("res: " + res);

        } catch (NoSuchMethodException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SecurityException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalArgumentException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InvocationTargetException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

}
